package com.summer.framework.system;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.summer.framework.core.entity.TenantBaseEntity;
import org.apache.ibatis.annotations.Mapper;

import java.nio.file.Paths;

/**
 * Description: 代码自动生成
 * @auther Ice Yang
 * Date 2025/7/17 15:48
 */
public class CodeGenerator {

    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://127.0.0.1:3306/summer-system", "root", "root123456")
                .globalConfig(builder -> builder
                        .author("Ice")
                        .outputDir(Paths.get(System.getProperty("user.dir")) + "/summer-system/src/main/java")
                        .commentDate("yyyy-MM-dd")
                )
                .packageConfig(builder -> builder
                        .parent("com.summer.framework.system")
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .controller("controller")
                        .xml("/xml")
                )
                .strategyConfig(builder -> builder
                        .addInclude("system_category", "system_category_value", "system_menu_info", "system_organization", "system_role_info", "system_role_menu", "system_user_org", "system_user_role")
                        .addTablePrefix("system_")
                        .controllerBuilder()
                        .enableRestStyle()
                        .serviceBuilder()
                        .formatServiceFileName("%sService")
                        .formatServiceImplFileName("%sServiceImpl")
                        .mapperBuilder()
                        .mapperAnnotation(Mapper.class)
                        .entityBuilder()
                        .enableLombok()
                        .entityBuilder()
                        .superClass(TenantBaseEntity.class)
                        .disableSerialVersionUID()
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
